import { Book } from '@/types/book'
import { Pagination, PageResult, PageParam } from '@/types/global'
import { http } from '@/utils/http'

type MyParams = Pagination & { subType?: string } // 定义类型 类型是Pagination的属性 + subType属性

export const addOrUpdateApi = (data?: Book) => {
  return http.post<Book>('/bk/book/addOrUpdate', data)
}

export const myBookListApi = (param: PageParam) => {
  return http.get<PageResult<Book>>('/bk/book/myBookList', param)
}

export const myPendingBookListApi = (param: PageParam) => {
  return http.get<PageResult<Book>>('/bk/book/myPendingBookList', param)
}

export const bookListByUserIdApi = (userId: number) => {
  return http.get<Book[]>('/bk/book/bookListByUserId', { userId })
}

export const bookInfoApi = (id: number) => {
  return http.get<Book>('/bk/book/bookInfo', { id })
}
